using System;
using UnityEngine;
using System.Collections.Generic;
using CommonFactory;

public class SkillItemInfo : ScriptableObject, IDataCollectionTemplete
{
    public List<SkillItemData> Data = new List<SkillItemData>();
    /// <summary>
    /// 获得内容Type
    /// </summary>
    public Type GetContenType()
    {
        return typeof(SkillItemData);
    }
    /// <summary>
    /// 通过ID获取数据
    /// </summary>
    public SkillItemData GetDataByID(int id)
    {
        for (int i = 0; i < Data.Count; i++)
        {
            if (Data[i].ID == id)
            {
                return Data[i];
            }
        }
        return null;
    }
    /// <summary>
    /// 转换成当前内容类型的列表
    /// </summary>
    public void ConvertToContentList(List<IDataTemplete> contents)
    {
        for (int i = 0; i < contents.Count; i++)
        {
            Data.Add((SkillItemData)contents[i]);
        }
    }
}


[Serializable]
public class SkillItemData : IDataTemplete
{
    /// <summary>
    /// 索引号
    /// </summary>
    public int ID;
    /// <summary>
    /// 名称
    /// </summary>
    public string Name;
    /// <summary>
    /// 特效
    /// </summary>
    public string Effect;
    /// <summary>
    /// 动作名称
    /// </summary>
    public string ActionName;
    /// <summary>
    /// 动作名称
    /// </summary>
    public string ActionParamsName;
    /// <summary>
    /// 等待时间
    /// </summary>
    public float WaitTime;
    /// <summary>
    /// 技能类型
    /// </summary>
    public int SkillType;

    public List<int> SkillLinkerType=new List<int>() { 1};

    public bool IsNoLinkWillBreak=true;

    public int DamageOpportunityType = 1;

    public string DamageResultArgs = "{\"ArgArray\":[{\"ResultType\":1,\"Args\":{\"ReduceValue\":100}},{\"ResultType\":1,\"Args\":{\"ReduceValue\":100}}]}";
    /// <summary>
    /// 技能发射器类型
    /// </summary>
    public int TransmitterType;
    /// <summary>
    /// 技能开角
    /// </summary>
    public float SkillAngle;
    /// <summary>
    /// 技能范围半径
    /// </summary>
    public float SkillRadius;
    /// <summary>
    /// 技能偏移值x
    /// </summary>
    public float SkillOffsetX;
    /// <summary>
    /// 技能偏移值y
    /// </summary>
    public float SkillOffsetY;
    /// <summary>
    /// 技能偏移值z
    /// </summary>
    public float SkillOffsetZ;
    /// <summary>
    /// 是否为空
    /// </summary>
    public bool IsEmpty { get; set; }
    /// <summary>
    /// 构造方法
    /// </summary>
    public SkillItemData()
    {
        IsEmpty = true;
        ID = default(int);
        Name = default(string);
        Effect = default(string);
        ActionName = default(string);
        ActionParamsName= default(string);
        WaitTime = default(float);
        SkillType = default(int);
        TransmitterType = default(int);
        SkillAngle = default(float);
        SkillRadius = default(float);
        SkillOffsetX = default(float);
        SkillOffsetY = default(float);
        SkillOffsetZ = default(float);
    }
    /// <summary>
    /// 反序列化
    /// </summary>
    public void DeSerialize(object[] content)
    {
        ID = string.IsNullOrEmpty(content[0].ToString()) ? 0 : Int32.Parse(content[0].ToString());
        Name = content[1].ToString();
        Effect = content[2].ToString();
        ActionName = content[3].ToString();
        ActionParamsName = content[4].ToString();
        WaitTime = string.IsNullOrEmpty(content[5].ToString()) ? 0 : float.Parse(content[5].ToString());
        SkillType = string.IsNullOrEmpty(content[6].ToString()) ? 0 : Int32.Parse(content[6].ToString());
        TransmitterType = string.IsNullOrEmpty(content[7].ToString()) ? 0 : Int32.Parse(content[7].ToString());
        SkillAngle = string.IsNullOrEmpty(content[8].ToString()) ? 0 : float.Parse(content[8].ToString());
        SkillRadius = string.IsNullOrEmpty(content[9].ToString()) ? 0 : float.Parse(content[9].ToString());
        SkillOffsetX = string.IsNullOrEmpty(content[10].ToString()) ? 0 : float.Parse(content[10].ToString());
        SkillOffsetY = string.IsNullOrEmpty(content[11].ToString()) ? 0 : float.Parse(content[11].ToString());
        SkillOffsetZ = string.IsNullOrEmpty(content[12].ToString()) ? 0 : float.Parse(content[12].ToString());
        for (int i = 0; i < content.Length; i++)
        {
            if (content[i] != null)
            {
                IsEmpty = false;
            }
        }
    }
}